<template>
  <a-modal
    :title="title"
    :width="800"
    :visible="visible"
    :confirmLoading="confirmLoading"
    @ok="handleOk"
    @cancel="handleCancel"
    :footer="null"
    cancelText="关闭">

    <table id="table_report" class="table table-striped table-bordered table-hover">

      <tr>
        <td style="width:90px;text-align: right;padding-top: 80px;">基本信息:</td>
        <td>
          <p style="float: left;">
            停车场编号：<span id="parkCode">
           {{ result.parkCode }}
                    </span><br>
            停车场名称：<span id="parkName">
           {{ result.parkName }}
                    </span><br>
            套餐名称：<span id="packageName">
           {{ result.packageName }}
                    </span><br>
            月租车辆类型名称：<span id="monthlyTypeName">
           {{ result.monthlyTypeName }}
                    </span><br>
            可绑定车位数：<span id="bindingSpaceNumber">
           {{ result.bindingSpaceNumber }}
                    </span><br>
            可绑定车辆数：<span id="bindingCarNumber">
           {{ result.bindingCarNumber }}
                    </span><br>
            延期周期单位：<span id="cycleLength">
           {{ result.cycleLength === 1 ? "1天" : "1月" }}
                    </span><br>
            周期单位收费金额(元)：<span id="charges">
           {{ parseFloat(result.charges / 100).toFixed(2) }}
                    </span><br>
            满位处理方式车辆类型名称：<span id="fullManageName">
           {{ result.fullManageName }}
                    </span><br>
            过期处理车辆类型名称：<span id="overdueTypeName">
           {{ result.overdueTypeName }}
                    </span><br>
            过期延期方式：<span id="overdueDelayWay">
           {{ result.overdueDelayWay === 1 ? "顺延" : "跳延" }}
                    </span><br>
            是否配置允许办理起始时间：<span id="allowHandleStarting">
           {{ result.allowHandleStarting === 1 ? "是" : "否" }}
                    </span><br>
            是否配置允许办理截至时间：<span id="allowHandleOf">
           {{ result.allowHandleOf === 1 ? "是" : "否" }}
                    </span><br>
            最大允许购周期数：<span id="maxCycle">
           {{ result.maxCycle }}
                    </span><br>
            是否允许线上购买：<span id="allowOnlineBuy">
           {{ result.allowOnlineBuy === 1 ? "允许" : "禁止" }}
                    </span><br>
            是否允许线上续费：<span id="allowOnlineRenewal">
           {{ result.allowOnlineRenewal === 1 ? "允许" : "禁止" }}
                    </span><br>
            备注：<span id="remark">
           {{ result.remark }}
                    </span><br>
            图片地址：<span id="imageUrl">
           {{ result.imageUrl }}
                    </span><br>
          </p>
        </td>
      </tr>

      <tr>
        <td style="width:90px;text-align: right;padding-top: 60px;">详情:</td>
        <td>
          <p style="float: left;">
            月租车辆类型id：<span id="monthlyTypeId">
           {{ result.monthlyTypeId }}
                    </span><br>
            满位处理方式车辆类型id：<span id="fullManageId">
           {{ result.fullManageId }}
                    </span><br>
            过期处理车辆类型id：<span id="overdueTypeId">
           {{ result.overdueTypeId }}
                    </span><br>
            是否固定车位：<span id="fixedSpace">
           {{ result.fixedSpace === 1 ? "固定" : "不固定" }}
                    </span><br>
            车位类型标识：<span id="spaceFlag">
           {{ result.spaceFlag === 1 ? "一车一位" : "多车多位" }}
                    </span><br>
            创建人id：<span id="createUserId">
           {{ result.createUserId }}
                    </span><br>
            创建人名称：<span id="createUserName">
           {{ result.createUserName }}
                    </span><br>
            修改人id：<span id="updateUserId">
           {{ result.updateUserId }}
                    </span><br>
            修改人名称：<span id="updateUserName">
           {{ result.updateUserName }}
                    </span><br>
            修改时间：<span id="updateTime">
           {{ result.updateTime }}
                    </span><br>
            创建时间：<span id="createTime">
           {{ result.createTime }}
                    </span><br>


          </p>
        </td>
      </tr>

      <tr>
        <td style="text-align: center;" colspan="10">
          <a-button type="primary" @click="close">关闭</a-button>
        </td>
      </tr>
    </table>

  </a-modal>
</template>

<script>
import {httpAction} from '@/api/manage'
import {JeecgListMixin} from '@/mixins/JeecgListMixin'
import pick from 'lodash.pick'
import moment from "moment"

export default {
  name: "MonthlyPackageInfoModalDetail",
  data() {
    return {
      title: "操作",
      visible: false,
      model: {},
      labelCol: {
        xs: {span: 24},
        sm: {span: 5},
      },
      wrapperCol: {
        xs: {span: 24},
        sm: {span: 16},
      },
      result: {},
      confirmLoading: false,
      form: this.$form.createForm(this),
      validatorRules: {
        parkCode: {rules: [{required: true, message: '请输入停车场编号!'}]},
      },
      url: {
        add: "/com.parking/monthlyPackageInfo/add",
        edit: "/com.parking/monthlyPackageInfo/edit",
      },
    }
  },
  created() {
  },
  methods: {
    add() {
      this.edit({});
    },
    edit(record) {
      Object.assign(this.result, record);
      this.visible = true;
    },
    close() {
      this.$emit('close');
      this.visible = false;
    },
    handleOk() {
      const that = this;
      // 触发表单验证
      this.form.validateFields((err, values) => {
        if (!err) {
          that.confirmLoading = true;
          let httpurl = '';
          let method = '';
          if (!this.model.id) {
            httpurl += this.url.add;
            method = 'post';
          } else {
            httpurl += this.url.edit;
            method = 'put';
          }
          let formData = Object.assign(this.model, values);
          //时间格式化
          formData.workParkStartTime = formData.workParkStartTime ? formData.workParkStartTime.format('YYYY-MM-DD HH:mm:ss') : null;
          formData.workParkEntTime = formData.workParkEntTime ? formData.workParkEntTime.format('YYYY-MM-DD HH:mm:ss') : null;
          formData.weekendParkStartTime = formData.weekendParkStartTime ? formData.weekendParkStartTime.format('YYYY-MM-DD HH:mm:ss') : null;
          formData.weekendParkEntTime = formData.weekendParkEntTime ? formData.weekendParkEntTime.format('YYYY-MM-DD HH:mm:ss') : null;
          formData.holidaysParkStartTime = formData.holidaysParkStartTime ? formData.holidaysParkStartTime.format('YYYY-MM-DD HH:mm:ss') : null;
          formData.holidaysParkEntTime = formData.holidaysParkEntTime ? formData.holidaysParkEntTime.format('YYYY-MM-DD HH:mm:ss') : null;
          formData.takeTime = formData.takeTime ? formData.takeTime.format('YYYY-MM-DD HH:mm:ss') : null;
          formData.updateTime = formData.updateTime ? formData.updateTime.format('YYYY-MM-DD HH:mm:ss') : null;

          httpAction(httpurl, formData, method).then((res) => {
            if (res.success) {
              that.$message.success(res.message);
              that.$emit('ok');
            } else {
              that.$message.warning(res.message);
            }
          }).finally(() => {
            that.confirmLoading = false;
            that.close();
          })


        }
      })
    },
    handleCancel() {
      this.close()
    },


  }
}
</script>

<style lang="less" scoped>

</style>